package xj.util.gui;

import java.io.File;

import javax.swing.filechooser.FileFilter;


public class MultiExtensionsFileFilter extends FileFilter {

  public MultiExtensionsFileFilter(String[] ext, String des) {
    extensions = ext;
    description = des;
  }

  @Override
  public boolean accept(File f) {
    if (f != null) {
      if (f.isDirectory()) {
	return true;
      }
      String ext = ExtensionFileFilter.getFileExtension(f);
      if (ext != null) {
	for (int i = 0; i < extensions.length; i++) {
	  if (ext.equals(extensions[i])) {
	    return true;
	  }
	}
      }
    }
    return false;
  }

  @Override
  public String getDescription() {
    return description;
  }

  protected String[] extensions;

  protected String description;

}
